import { Reducer } from 'redux';

export interface PermissionItem {
  id: Number;
  permissionCode: string;
}

export interface PermissionModelState {
  permissionList: PermissionItem[];
}

export interface PermissionModelType {
  namespace: string;
  state: PermissionModelState;
  effects: {};
  reducers: {
    addPermission: Reducer<PermissionModelState>;
  };
}

const MenuModel: PermissionModelType = {
  namespace: 'permission',
  state: {
    permissionList: [],
  },
  effects: {},

  reducers: {
    addPermission(state = { permissionList: [] }, { payload }) {
      return {
        ...state,
        permissionList: payload,
      };
    },
  },
};

export default MenuModel;
